﻿@model HomeStayWebCP.Models.BusinessObject.NewObject
       
@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

<!DOCTYPE html>

<html>
<head>
    <title>AddNew</title>
    <script src="../../Plugin/ckeditor/ckeditor.js" type="text/javascript"></script>
    <script type="text/javascript"  src="../../Plugin/ckeditor/adapters/jquery.js"></script>
    <style type="text/css">
        label {
            float: left;
            margin-right: 10px;
            width: 50px;
        }
        .field-validation-error {
            color: red;
        }
        span {
            color: red;
        }
        #postnew {
            color: #5b0f32;
            cursor: pointer;
        }
    </style>
</head>
<body>
        
@using (Html.BeginForm("CreateNew","ManageNews",FormMethod.Post, new { enctype = "multipart/form-data"}))
{
    <div style="padding: 5px">
       
            

            <div class="editor-label">
                @Html.LabelFor(m => m.Title)
            </div> 
            
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Title,new {style="width:500px"})
                @Html.ValidationMessageFor(m => m.Title)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Header)
            </div> 
            <div class="editor-field">
                @Html.TextBoxFor(m => m.Header, new { style = "width:500px" })
                @Html.ValidationMessageFor(m => m.Header)
            </div>
            <div class="editor-label">
                @Html.LabelFor(m => m.Image)
                   
            </div> 
             <div class="editor-field">
                 <input type="file" name="test" id="imagefile"/>
                 <span></span>
            </div> 
     
             <div class="editor-label">
            
                @Html.TextAreaFor(m => m.Content, new { @id = "ckeContent" })
               
                     <span></span>
                 <script type="text/javascript">                    CKEDITOR.replace("ckeContent");</script> 
            </div>

        <p>
            <input type="submit" value="Add" style="display: none" id="submitbtn"/>
        </p>
        <p>
            <input type="button" value="Add" id="addbtn" onclick="Check()" />
         </p>
        
    </div>
}

    <script type="text/javascript">
       
          var errormes = $('#imagefile').next('span');
          var errormes2 = $('#ckeContent').next('span');
          function Check()
          {
                if ($('#imagefile').val() == "") {
                  $(errormes).css('display', 'block');
                    $(errormes).html('Image is required');
                    return false;
                } else {
                    $(errormes).css('display', 'none');
                }
//                
               
                    $('#submitbtn').click();
               
            }

       
    </script>
</body>
</html>
